home *** CD-ROM | disk | FTP | other *** search
/ Freelog 117 / FreelogNo117-OctobreNovembre2013.iso / Programmation / jedit / jedit5.1.0install.exe / {app} / macros / Clipboard / Copy_Lines_Containing.bsh next >
Text File  |  2013-07-28  |  1KB  |  33 lines

  1. /*
  2.  * Copy_Lines_Containing.bsh - Copies lines from current buffer that
  3.  * contain a user-supplied string to the clipboard.
  4.  * 
  5.  * Copyright (C) 2004 Ollie Rutherfurd <oliver@jedit.org>
  6.  *
  7.  * $Id: Copy_Lines_Containing.bsh 21353 2012-03-14 09:46:51Z jojaba_67 $
  8.  */
  9.  
  10. //Localization
  11. final static String CopyLinesContainingLabel = jEdit.getProperty("macro.rs.CopyLinesContaining.CopyLinesContaining.label", "Copy lines containing:");
  12. final static String LinesCopiedMessage = jEdit.getProperty("macro.rs.CopyLinesContaining.LinesCopied.message", "line(s) copied"); 
  13.  
  14. copyLinesContaining(){
  15.     String text = Macros.input(view, CopyLinesContainingLabel);
  16.     if(text == null || "".equals(text))
  17.         return;
  18.     int count = 0;
  19.     StringBuffer buff = new StringBuffer();
  20.     for(int i = 0; i < buffer.getLineCount(); i++){
  21.         String line = buffer.getLineText(i);
  22.         if(line.indexOf(text) > -1){
  23.             buff.append(line).append('\n');
  24.             count++;
  25.         }
  26.     }
  27.     Registers.setRegister('$',buff.toString());
  28.     HistoryModel.getModel("clipboard").addItem(buff.toString());
  29.     view.getStatus().setMessageAndClear(count + " " + LinesCopiedMessage);
  30. }
  31.  
  32. copyLinesContaining();
  33.